From 38dd316259194d158f128fb90049df8c29bdb6d5 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Tue, 28 Nov 2006 21:40:42 +0000 Subject: [PATCH] Fix broken contribution listings with postgres by adding a new variable to check if we are using integers or explicit timestamps. --- includes/Database.php | 8 ++++++++ includes/DatabasePostgres.php | 1 + includes/SpecialContributions.php | 8 +++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index e707546352..5f5601f101 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -250,6 +250,7 @@ class Database { protected $mCascadingDeletes = false; protected $mCleanupTriggers = false; protected $mStrictIPs = false; + protected $mRealTimestamps = false; #------------------------------------------------------------------------------ # Accessors @@ -362,6 +363,13 @@ class Database { return $this->mStrictIPs; } + /** + * Returns true if this database uses timestamps rather than integers + */ + function realTimestamps() { + return $this->mRealTimestamps; + } + /**#@+ * Get function */ diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index 0ff74edfb9..805313dab9 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -28,6 +28,7 @@ class DatabasePostgres extends Database { $this->mCascadingDeletes = true; $this->mCleanupTriggers = true; $this->mStrictIPs = true; + $this->mRealTimestamps = true; $this->mFlags = $flags; $this->open( $server, $user, $password, $dbName); diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index f9fe14ef29..090725642f 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -185,9 +185,11 @@ function wfSpecialContributions( $par = null ) { list( $options['limit'], $options['offset']) = wfCheckLimits(); $options['offset'] = $wgRequest->getVal( 'offset' ); - /* Offset must be an integral. */ - if ( !strlen( $options['offset'] ) || !preg_match( '/^[0-9]+$/', $options['offset'] ) ) - $options['offset'] = ''; + /* Offset must be an integral, unless the db is using timestamps */ + $dbr =& wfGetDB( DB_SLAVE ); + if ( !strlen( $options['offset'] ) || + ( !$dbr->realTimestamps() && !preg_match( '/^[0-9]+$/', $options['offset'] ) ) ) + $options['offset'] = ''; $title = SpecialPage::getTitleFor( 'Contributions' ); $options['target'] = $target; -- 2.20.1